fix(rsc): handle export * re-exports in use client modules#1234
Open
james-elicx wants to merge 3 commits into
Open
fix(rsc): handle export * re-exports in use client modules#1234james-elicx wants to merge 3 commits into
export * re-exports in use client modules#1234james-elicx wants to merge 3 commits into
Conversation
The `use-client` proxy transform threw `unsupported ExportAllDeclaration` on any `"use client"` file containing `export * from '...'`. Pre-resolve bare `export *` declarations to explicit named re-exports before running the proxy transform (mirroring Next.js's webpack plugin behavior), and handle `export * as ns from` directly in the pure proxy/wrap transforms since the name is statically known. Closes cloudflare/vinext#1352
hi-ogawa
reviewed
May 22, 2026
hi-ogawa
reviewed
May 22, 2026
Contributor
hi-ogawa
left a comment
There was a problem hiding this comment.
Thanks for working on this. The idea makes sense to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
use-clientproxy transform in@vitejs/plugin-rscthrowsunsupported ExportAllDeclarationwhenever a"use client"file containsexport * from '...'. Reported downstream in cloudflare/vinext#1352, where Next.js's app-dir test suite hits this with a real-worldcomponents/export-all/index.jsfixture.fixes #1233
Reproduction
A new fixture under
packages/plugin-rsc/examples/basic/src/routes/export-all/reproduces the original error onmain:It builds cleanly with the fix.
Fix
Pure transforms (
proxy-export.ts,wrap-export.ts) now handle theexport * as ns from '...'form directly, since the namespace name is statically known.Plugin layer (
plugin.ts) introduces anexpandExportAllDeclarationshelper used by bothvitePluginUseClientandvitePluginUseServer. For each bareexport * from '...'declaration, it resolves the source, recursively collects the named exports via AST walk, and rewrites the source toexport { a, b, c } from '...'before the proxy transform runs. This mirrors what Next.js's webpack plugin does to pre-resolveexport *into named exports.this.load({ id }).code(which Rollup populates).ModuleInfo.codeis unsupported andtransformRequestreturns module-runner output (__vite_ssr_exportName__(...)) that lacks readable ESM exports, so it falls back tofs.readFile+transformWithOxcto get standard JS the AST walk can read.Test plan
proxy-export.test.tsforexport * as ns from, the post-resolution form, theignoreExportAllDeclarationescape hatch, and the still-thrown unresolved-bare case; updatedwrap-export.test.tssnapshot. All 428 unit tests pass.export *inbasic.test.tsagainst the new fixture. All 151 basic e2e tests pass in both dev and build modes.main(stashed the fix, rebuilt, build fails with the exact error from the issue) and disappears with the fix.